package ua.com.minus1.lookbattle;

import android.content.Context;
import android.graphics.drawable.Drawable;
import ua.com.minus1.lookbattle.net.URLManager;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * User: Flash
 * Date: 17.07.12
 * Time: 15:38
 * To change this template use File | Settings | File Templates.
 */
public class CatItemFactory {
    private static final int CAT_WOMAN = 1;
    private static final int CAT_MAN = 2;
    private static final int CAT_CAT = 3;
    private static final int CAT_DOG = 4;
    private static final int CAT_CAR = 5;
    private static final int CAT_ART = 6;

    private static final Integer[] icons = {
            R.drawable.man, R.drawable.woman,
            R.drawable.cat, R.drawable.dog,
            R.drawable.car, R.drawable.art
    };

    private static final Integer[] labels = {
            R.string.man_cat, R.string.woman_cat,
            R.string.cat_cat, R.string.dog_cat,
            R.string.car_cat, R.string.art_cat
    };

    private static final Integer[] catIds = {
            CAT_MAN, CAT_WOMAN,
            CAT_CAT, CAT_DOG,
            CAT_CAR, CAT_ART
    };

    public static CatItem[] createItems(Context context) {
        CatItem[] catItems = new CatItem[icons.length];
        for (int i = 0; i < icons.length; i++) {
            Drawable icon = context.getResources().getDrawable(icons[i]);
            catItems[i] = new CatItem(icon, context.getResources().getString(labels[i]), catIds[i]);
        }
        return catItems;
    }

    public static int getCatPositionId(int catId) {
        return Arrays.asList(catIds).indexOf(catId);
    }

    public static int getCatsCount()
    {
        return catIds.length;
    }

    public static int getCatIdOnPosition(int position) {
        return catIds[position];
    }

    public static class CatItem {
        public Drawable icon;
        public String label;
        public Integer catId;

        public CatItem(Drawable icon, String label, Integer catId) {
            this.icon = icon;
            this.label = label;
            this.catId = catId;
        }
    }
}
